<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- paintsystem.qdoc -->
  <title>Paint Devices and Backends | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td >Paint Devices and Backends</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="next" href="paintsystem-drawing.html" />
<p class="naviNextPrevious headerNavi">
<a class="nextPage" href="paintsystem-drawing.html">Drawing and Filling</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#creating-a-paint-device">Creating a Paint Device</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Paint Devices and Backends</h1>
<span class="subtitle"></span>
<!-- $$$paintsystem-devices.html-description -->
<div class="descr"> <a name="details"></a>
<a name="creating-a-paint-device"></a>
<h2 id="creating-a-paint-device">Creating a Paint Device</h2>
<p>The <a href="qpaintdevice.html">QPaintDevice</a> class is the base class of objects that can be painted, i.e&#x2e; <a href="qpainter.html">QPainter</a> can draw on any <a href="qpaintdevice.html">QPaintDevice</a> subclass. <a href="qpaintdevice.html">QPaintDevice</a>'s drawing capabilities are among others implemented by <a href="../qtwidgets/qwidget.html">QWidget</a>, <a href="qimage.html">QImage</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qpicture.html">QPicture</a>, QPrinter, and <a href="qopenglpaintdevice.html">QOpenGLPaintDevice</a>.</p>
<div class="table"><table class="generic" width="100%">
 <tr valign="top" class="odd"><td ><b>Widget</b><p>The <a href="../qtwidgets/qwidget.html">QWidget</a> class is the base class of user interface elements in the <a href="../qtwidgets/qtwidgets-index.html">Qt Widgets</a> module. It receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen.</p>
</td></tr>
<tr valign="top" class="even"><td ><b>Image</b><p>The <a href="qimage.html">QImage</a> class provides a hardware-independent image representation which is designed and optimized for I/O, and for direct pixel access and manipulation. <a href="qimage.html">QImage</a> supports several image formats including monochrome, 8-bit, 32-bit and alpha-blended images.</p>
<p>One advantage of using <a href="qimage.html">QImage</a> as a paint device is that it is possible to guarantee the pixel exactness of any drawing operation in a platform-independent way. Another benefit is that the painting can be performed in another thread than the current GUI thread.</p>
</td></tr>
<tr valign="top" class="odd"><td ><b>Pixmap</b><p>The <a href="qpixmap.html">QPixmap</a> class is an off-screen image representation which is designed and optimized for showing images on screen. Unlike <a href="qimage.html">QImage</a>, the pixel data in a pixmap is internal and is managed by the underlying window system, i.e&#x2e; pixels can only be accessed through <a href="qpainter.html">QPainter</a> functions or by converting the <a href="qpixmap.html">QPixmap</a> to a <a href="qimage.html">QImage</a>.</p>
<p>To optimize drawing with <a href="qpixmap.html">QPixmap</a>, Qt provides the <a href="qpixmapcache.html">QPixmapCache</a> class which can be used to store temporary pixmaps that are expensive to generate without using more storage space than the cache limit.</p>
<p>Qt also provides the <a href="qbitmap.html">QBitmap</a> convenience class, inheriting <a href="qpixmap.html">QPixmap</a>. <a href="qbitmap.html">QBitmap</a> guarantees monochrome (1-bit depth) pixmaps, and is mainly used for creating custom <a href="qcursor.html">QCursor</a> and <a href="qbrush.html">QBrush</a> objects, constructing <a href="qregion.html">QRegion</a> objects.</p>
</td></tr>
<tr valign="top" class="even"><td ><b>OpenGL Paint Device</b><p>As mentioned previously, Qt is offering classes that makes it easy to use OpenGL in Qt applications. For example, the <a href="qopenglpaintdevice.html">QOpenGLPaintDevice</a> enables the OpenGL API for rendering with <a href="qpainter.html">QPainter</a>.</p>
</td></tr>
<tr valign="top" class="odd"><td ><b>Picture</b><p>The <a href="qpicture.html">QPicture</a> class is a paint device that records and replays <a href="qpainter.html">QPainter</a> commands. A picture serializes painter commands to an IO device in a platform-independent format. <a href="qpicture.html">QPicture</a> is also resolution independent, i.e&#x2e; a <a href="qpicture.html">QPicture</a> can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same.</p>
<p>Qt provides the <a href="qpicture.html#load">QPicture::load</a>() and <a href="qpicture.html#save">QPicture::save</a>() functions as well as streaming operators for loading and saving pictures.</p>
</td></tr>
<tr valign="top" class="even"><td ><b>Custom Backends</b><p>Support for a new backend can be implemented by deriving from the <a href="qpaintdevice.html">QPaintDevice</a> class and reimplementing the virtual <a href="qpaintdevice.html#paintEngine">QPaintDevice::paintEngine</a>() function to tell <a href="qpainter.html">QPainter</a> which paint engine should be used to draw on this particular device. To actually be able to draw on the device, this paint engine must be a custom paint engine created by deriving from the <a href="qpaintengine.html">QPaintEngine</a> class.</p>
</td></tr>
</table></div>
</div>
<!-- @@@paintsystem-devices.html -->
<p class="naviNextPrevious footerNavi">
<a class="nextPage" href="paintsystem-drawing.html">Drawing and Filling</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
